Auto-subscribe symbols when registering indicators and consolidators#9582
Merged
Martin-Molinero merged 1 commit intoJul 2, 2026
Conversation
Registering an indicator or consolidator for a symbol that had not been subscribed to threw 'Please register to receive data for symbol ...'. Order submission already auto-subscribes the symbol on the user's behalf; this applies the same behavior to indicator/consolidator registration. GetSubscription now adds the security automatically when it has no subscription (guarded by the shared CanAutoAddSecurity check, which is also used by order submission) before falling back to the error. The subscription lookup is exposed via a TryGetSubscription out-parameter helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Registering an indicator or a consolidator for a symbol that has not been subscribed to used to throw:
Order submission already auto-subscribes a symbol on the user's behalf (see
GetSecurityForOrder). This PR applies the same behavior to indicator and consolidator registration:GetSubscriptionnow adds the security automatically when it has no subscription, before falling back to the error message.Details:
CanAutoAddSecurityhelper, now used by bothGetSecurityForOrderandGetSubscription. Order submission keeps its extraSecurityType != Indexcheck (indexes are not tradable), while the subscription path allows indexes since it only needs their data.GetSubscriptionwas refactored into abool TryGetSubscription(..., out SubscriptionDataConfig subscription)helper, replacing the previous try/catch control flow.Related Issue
N/A
Motivation and Context
Users can already trade a symbol without subscribing to it (order submission subscribes it automatically). It is surprising and inconsistent that registering an indicator or consolidator for that same symbol throws instead. This makes the behavior consistent across the API.
Requires Documentation Change
No.
How Has This Been Tested?
RegisterIndicatorAndConsolidatorWithoutSubscriptionRegressionAlgorithm, which never callsAddEquity/AddSecurityand:MarketOrderfor a separate, unsubscribed symbol (AIG) (exercising the order-submission auto-add), asserting the order is placed and filled and that the position is established.master(throws during initialization) and passes with this change.AlgorithmIndicatorsTests,AlgorithmResolveConsolidatorTests,AlgorithmRegisterIndicatorTests,AlgorithmSubscriptionManagerRemoveConsolidatorTests.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>